package cc.bluemc.modules.generateCode.entity;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class FileStruct {
	
	public static final String type_file="f";
	public static final String type_directory="d";
	private String fileName;
	
	private String parent;
	
	private String type;
	
	private String suffix;
	
	private List<FileStruct> childs=new ArrayList<FileStruct>();
	
	private String path;

	public FileStruct() {
	}
	public FileStruct(File file) {
		this.fileName=file.getName();
		this.parent=file.getParent();
		this.path = file.getPath();
		if(file.isDirectory()){
			this.type=type_directory;
			File[] childFiles = file.listFiles();
			for(File f : childFiles){
				this.childs.add(new FileStruct(f));
			}
		}else{
			this.type=type_file;
			this.suffix=this.fileName.replaceAll("^.*?\\.(.*)$", "$1");
		}
	}
	public String getFileName() {
		return fileName;
	}
	public String getParent() {
		return parent;
	}
	public String getType() {
		return type;
	}
	public String getSuffix() {
		return suffix;
	}
	public List<FileStruct> getChilds() {
		return childs;
	}
	public String getPath() {
		return path;
	}
	

}
